Skip to content

make a webhook to remind us to run the needful make commands#4659

Open
hlipsig wants to merge 3 commits intomasterfrom
hlipsig/ARO-0000-pre-commmit-make-hook
Open

make a webhook to remind us to run the needful make commands#4659
hlipsig wants to merge 3 commits intomasterfrom
hlipsig/ARO-0000-pre-commmit-make-hook

Conversation

@hlipsig
Copy link
Copy Markdown
Collaborator

@hlipsig hlipsig commented Mar 5, 2026

What this PR does / why we need it:

Should help developers close the loop between a code change and a forgotten make command captured by CI.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 5, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Copy Markdown
Collaborator

@rajdeepc2792 rajdeepc2792 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two Arguments:

  1. Can we do a pre-push rather than a pre-commit?
  2. I am in with keeping it as simple as asking question, but can we advance it to notify only when no change is detected after running the required make?

@hlipsig
Copy link
Copy Markdown
Collaborator Author

hlipsig commented Mar 5, 2026

Two Arguments:

  1. Can we do a pre-push rather than a pre-commit?
  2. I am in with keeping it as simple as asking question, but can we advance it to notify only when no change is detected after running the required make?
  1. Yeah that's a good point.
  2. I'm not sure I understand. Can you explain what the workflow would be?

echo " - make generate"
echo " - make imports"
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elaborating on the second point:

  • Executing all the required make targets as part of the script
  • Running git status --porcelain to detect modified or untracked files
  • Fail and ask to run the required make commands and keep the local repo clean after commits.

PS: I always have some modified/untracked files on my local, so I would not prefer this flow. But a suggestion.
I believe asking every time during push is fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to have to maintain all the required make commands within the script hence this implementation just being a nag vs total automation.

echo " - make generate"
echo " - make imports"
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to have to maintain all the required make commands within the script hence this implementation just being a nag vs total automation.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a local Git hook intended to remind contributors to run commonly-forgotten make targets before pushing, helping prevent CI failures due to missing generated/import updates.

Changes:

  • Introduce a new pre-push hook that prompts developers to confirm they ran required make commands.
  • Simplify the existing pre-commit hook by removing an explicit exit 0 at the end.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hack/git/hooks/pre-push New interactive pre-push check prompting users to run key make targets before pushing.
hack/git/hooks/pre-commit Minor cleanup: remove redundant trailing exit 0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +11
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-push hooks receive the list of refs to push on stdin. Using read -p without redirecting will read from that stdin (consuming a ref line) instead of from the user, which can cause the hook to abort pushes unexpectedly (often every time). Read the confirmation from /dev/tty (or similar) and/or guard for non-interactive environments so pushes from automation/IDEs don't hang or fail due to EOF.

Suggested change
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
# Only prompt when an interactive terminal is available.
if [ -t 0 ] || [ -t 1 ]; then
# Read from /dev/tty so we don't consume Git's stdin (the list of refs).
if ! read -r -p "Have you run all required make commands? [y/N] " run_make_commands </dev/tty; then
# If we cannot read from the terminal, allow the push to proceed.
exit 0
fi
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
fi

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's comment here makes sense to me, but we're probably fine without it. I can't imagine when/why we'd want automation pushing to this repo.

echo " - make imports"
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message says "Commit aborted" but this is a pre-push hook; it should say "Push aborted" (or similar) to avoid confusion.

Suggested change
echo "Commit aborted. Run the required make commands and try again."
echo "Push aborted. Run the required make commands and try again."

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@kimorris27 kimorris27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should go with one of Copilot's suggestions, but LGTM otherwise!

Comment on lines +8 to +11
read -r -p "Have you run all required make commands? [y/N] " run_make_commands
if [[ ! "${run_make_commands}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo "Commit aborted. Run the required make commands and try again."
exit 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's comment here makes sense to me, but we're probably fine without it. I can't imagine when/why we'd want automation pushing to this repo.

exit 1
fi

exit 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Did you mean to put this here? Asking since you removed it from the existing pre-commit hook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants